import { TCopyScore } from "../../../Message/Db/Tables/TCopyScore";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { SkillStateConfig } from "./SkillStateConfig";
type int = number;
//class CopyScoreConfig
    
    export  class CopyScoreConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            this._coinCopyAry = new Array<any>();
            if (CopyScoreConfig._instance != null) 
            {
                throw new Error(" Config 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TCopyScore();
                loc1.id = loc2.id;
                loc1.copyId = loc2.copyId;
                loc1.type = loc2.type;
                loc1.level = loc2.level;
                loc1.score = StringHelper.getString(loc2.score);
                loc1.evenCutInterval = loc2.evenCutInterval;
                loc1.evenCutBossInterval = loc2.evenCutBossInterval;
                loc1.deathClearEvenCut = loc2.deathClearEvenCut;
                loc1.evenCutBuff = StringHelper.getString(loc2.evenCutBuff);
                this._map[loc1.copyId] = loc1;
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_copy_score.json");
            this.write(loc1);
            return;
        }

        public getInfoByCode(arg1: int): TCopyScore
        {
            return this._map[arg1];
        }

        /* internal  */setCoinCopyValue(): void
        {
            var loc6=null;
            var loc7=null;
            var loc8=null;
            var loc9=0;
            if (this._isInitKeyValue) 
            {
                return;
            }
            var loc1=127;
            var loc2=this.getInfoByCode(loc1);
            var loc3=loc2.evenCutBuff;
            var loc4=loc3.split("]");
            var loc5=0;
            while (loc5 < loc4.length) 
            {
                if (loc6 = loc4[loc5]) 
                {
                    loc7 = (loc6 = loc6.substring(1)).split(",");
                    (loc8 = new KeyValue()).key = int(loc7[0]);
                    loc9 = int(loc7[1]);
                    loc8.value = SkillStateConfig.instance.getInfoByName(loc9).stateEffect;
                    this._coinCopyAry.push(loc8);
                }
                ++loc5;
            }
            this._isInitKeyValue = true;
            return;
        }

        public getCoinCopyAddNumByCutDown(arg1: int): int
        {
            var loc2=null;
            this.setCoinCopyValue();
            var loc1=0;
            while (loc1 < this._coinCopyAry.length) 
            {
                loc2 = this._coinCopyAry[loc1];
                if (loc2.key > arg1) 
                {
                    if (loc1 == 0) 
                    {
                        return 0;
                    }
                    return (this._coinCopyAry[(loc1 - 1)] as KeyValue).value;
                }
                ++loc1;
            }
            return 0;
        }

        public getCoinCopyNextKeyValueByByCutDown(arg1: int): KeyValue
        {
            var loc2=null;
            this.setCoinCopyValue();
            var loc1=0;
            while (loc1 < this._coinCopyAry.length) 
            {
                loc2 = this._coinCopyAry[loc1];
                if (loc2.key > arg1) 
                {
                    return this._coinCopyAry[loc1] as KeyValue;
                }
                ++loc1;
            }
            return null;
        }

        public static get instance(): CopyScoreConfig
        {
            if (CopyScoreConfig._instance == null) 
            {
                CopyScoreConfig._instance = new CopyScoreConfig();
            }
            return CopyScoreConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_coinCopyAry: Array<any>;

        /* internal */ /* var */_isInitKeyValue: Boolean=false;

        /* internal */ static /* var */_instance: CopyScoreConfig;
    }
}


class KeyValue
{
    public KeyValue()
    {
        
        return;
    }

    public /* var */key: int;

    public /* var */value: int;
